package com.teemor.demo.juc;

import java.util.concurrent.locks.AbstractQueuedSynchronizer;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Description:
 * @author zhoulk
 * @date: 2020/5/9
 */
public class AQSDemo {

    public static void main(String[] args) throws InterruptedException {
//        AbstractQueuedSynchronizer abstractQueuedSynchronizer = new AbstractQueuedSynchronizer() {
//            @Override
//            protected boolean tryAcquire(int arg) {
//                return super.tryAcquire(arg);
//            }
//        };
        ReentrantLock lock = new ReentrantLock();
        lock.lock();
        lock.unlock();
//
//        Condition condition = lock.newCondition();
//        condition.await();


        Thread thread = new Thread(() -> {
           lock.lock();
           lock.lock();
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            lock.unlock();
        });


        thread.start();

        Thread thread1 = new Thread(() -> {
            System.out.println("thread1-1");
            lock.lock();
            System.out.println("thread1-2");
            lock.unlock();
            System.out.println("thread1-3");
        });

    }


}
